package com.ev.k3cloudBusiness.service.impl;

import com.alibaba.fastjson.JSON;
import com.ev.k3cloud.entity.K3CloudBillSaveBaseEntity;
import com.ev.k3cloud.entity.K3CloudTopEntity;
import com.ev.k3cloud.enums.K3CloudBillFormId;
import com.ev.k3cloud.service.K3CloudService;
import com.ev.k3cloudBusiness.service.K3PurRequisitionService;
import com.ev.k3cloudBusiness.vo.K3PurRequisitionInsertVo;
import com.squareup.moshi.Json;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class K3PurRequisitionServiceImpl implements K3PurRequisitionService {
    @Autowired
    K3CloudService k3CloudService;
    @Override
    public String insert(K3PurRequisitionInsertVo param) {
        K3CloudBillSaveBaseEntity saveBaseEntity=new K3CloudBillSaveBaseEntity();
        saveBaseEntity.setModel(param);
        //开启保存自动审核
        saveBaseEntity.setIsAutoSubmitAndAudit(true);
        K3CloudTopEntity topEntity=new K3CloudTopEntity();
        topEntity.setData(saveBaseEntity);
        topEntity.setFormid(K3CloudBillFormId.PUR_REQUISITION.getFormId());
        return k3CloudService.save(JSON.toJSONString(topEntity));
    }
}
